ColorLib ver 1.0 by Reverend//HTB

1. What is it?
This is a small library made to create the so-called 'color buttons'. They are flat and colorful buttons with 'hover' option, known for example from html. After pointing on or clicking on a button, the color changes. The library was written in pure assembly, so it is small.

2. How to use it?
The library may be used by FASM programmers and by users of any other compiler that supports using .obj or .lib files (MS COFF) - in fact, nearly all compilers for windows are capable of this nowadays :) To create a 'color button' you must call one of 2 functions given by the library.

2a. FASM
To be able to use ColorLib in FASM you must include 'source\colorlib.ash' file.

 I. CButton. EAX contains returned handle

	push	id		;; unique button id
	push	height		;; height of button
	push	width		;; width of button
	push	y		;; y coordinate
	push	x		;; x coordinate
	push	rgb_color	;; color rgb - text when btn is clicked
	push	rgb_color	;; color rgb - text when btn is not clicked
	push	rgb_color	;; color rgb - 'hover'
	push	rgb_color	;; color rgb - when btn is clicked
	push	rgb_color	;; color rgb - when btn is not clicked
	push	text		;; text on the button
	push	instance	;; instance handle
	push	hwnd		;; handle of parent window
	call	CButton 	;; call to proc
	mov	[hButton], eax	;; save the returned handle

    NP.

	push	1		;; id = 1
	push	30		;; height = 30
	push	120		;; width = 120
	push	5		;; x = 5
	push	5		;; y = 5
	push	00FF0000h	;; color blue
	push	0000FF00h	;; color green
	push	000000FFh	;; color red
	push	00FFFFFFh	;; color white
	push	00000000h	;; color black
	push	szText		;; text under 'szText' offset
	push	[hInstance]	;; [hInstance] contains the instance handle
	push	[hWnd]		;; handle of parent window
	call	CButton 	;; call to proc
	mov	[hButton], eax	;; save the returned handle

 II. CButtonIndirect. You can also create a button indirectly. You must only fill the structure correctly and call this function giving offset to the structure as parameter.

  IIa. Structure definition

	struct CBUTTON
	  hParent		dd ?	;; handle of parent window
	  hInstance		dd ?	;; instance handle
	  szBtnText		dd ?	;; text on the button
	  dwBtnColor		dd ?	;; color rgb - when btn is not clicked
	  dwBtnClickedColor	dd ?	;; color rgb - when btn is clicked
	  dwBtnHoverColor	dd ?	;; color rgb - 'hover'
	  dwBtnTextColor	dd ?	;; color rgb - text when btn is not clicked
	  dwBtnTextClickedColor dd ?	;; color rgb - text when btn is clicked
	  nX			dd ?	;; x coordinate
	  nY			dd ?	;; y coordinate
	  nWidth		dd ?	;; width of button
	  nHeight		dd ?	;; height of button
	  nId			dd ?	;; unique button id
	ends

  IIb. Use of function

	push	cbutton_strucutre	;; pointer to structure
	call	CButtonIndirect 	;; call of function

2b. MASM
In MASM everything is nearly as in FASM. But you must compile with 'source\colorlib.lib' or 'source\colorlib.obj'. Prototypes of functions and structure declaration is in 'source\colorlib.inc'. You call the functions analogically to FASM

2c. C
You must compile with 'source\colorlib.obj' or 'source\colorlib.lib'. Header file is in 'source\colorlib.h'.

 I. CButton

	HANDLE hButton = CButton(hwnd, hInstance, "Example", 0x00FF0000, 0x0000FF00,\
			 0x000000FF, 0x00FFFFFF, 0x00000000, 5, 5, 120, 30, 1);
 II. CButtonIndirect

	CBUTTON cb;
	LPCBUTTON lpcb;

	cb.hParent = hwnd;
	cb.hInstance = hInstance;
	cb.szBtnText = "Example";
	cb.dwBtnColor = 0x00FF0000;
	cb.dwBtnClickedColor = 0x0000FF00;
	cb.dwBtnHoverColor = 0x000000FF;
	cb.dwBtnTextColor = 0x00FFFFFF;
	cb.dwBtnTextClickedColor = 0x00000000;
	cb.nX = 5;
	cb.nY = 5;
	cb.nWidth = 120;
	cb.nHeight = 30;
	cb.nId = 1;
	HANDLE hButton = CButtonIndirect(lpcb);

3. Examples
In the 'examples' directory, there are examples of using this library in FASM, MASM and Dev-Cpp.

4. The end
The idea and original code was written by payteR//ex.HTB
Every suggestions, opinions, questions, bugs please send to rev15@wp.pl

Reverend